//
//  SpecialProductGoodsTableViewCell.m
//  Youhuiju
//
//  Created by 余尚飞 on 16/8/5.
//  Copyright © 2016年 yutenys. All rights reserved.
//

#import "SpecialProductGoodsTableViewCell.h"

#import "SpecialProductGoodsCollectionViewCell.h"

@interface SpecialProductGoodsTableViewCell ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,CategoryButtonClicked>
@property (weak, nonatomic) IBOutlet UIImageView *sectionImg;

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;


//适配
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *sectionImgHeight;




@end

static NSString *SpecialProductGoodsCollectionViewCellIden = @"SpecialProductGoodsCollectionViewCellIden";

@implementation SpecialProductGoodsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    
    
    self.sectionImgHeight.constant = 51 * FitH;
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    
    [self.collectionView registerNib:[UINib nibWithNibName:@"SpecialProductGoodsCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:SpecialProductGoodsCollectionViewCellIden];
    
    
    
}

#pragma mark -------- collectionView delegate
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(166 * FitW, 222 * FitH);
}
//纵向
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 17 * FitH;
}
//横向
//-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
//{
//    
//}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(10 * FitH, 14 * FitW, 0, 14 * FitW);
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    SpecialProductGoodsCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:SpecialProductGoodsCollectionViewCellIden forIndexPath:indexPath];
    cell.layer.cornerRadius = 5 * FitH;
    cell.CategoryButtonDelegate = self;
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
//    DLog(@"当前是：从特惠产品跳转到商品详情");
    
    [self.table_collectCellDelegate clickedJump];
    
}

#pragma mark ------ pravite delegate
-(void)addShopCart:(NSString *)thisIsAModel
{
    [self.addShopCartDelegate addShopCartAction:thisIsAModel];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
